"use strict";
define(["jquery"], function () {
    var getTimeUtil =  {
        // 获取当前日期
        timeTimer: null,
        getNowDate: function () {
            var nowDate = new Date(),
                dayArr = ["星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
                year = nowDate.getFullYear(),
                month = nowDate.getMonth() + 1,
                day = nowDate.getDate(),
                dateString = "";
            dateString = year + "年" + month + "月" + day + "日";
            $(".headerTime .dateText").text(dateString);

            getTimeUtil.timeTimer = setTimeout(getTimeUtil.getTimeInfo, 1000);
        },
        // 获取当前时间
        getTimeInfo: function () {
            clearTimeout(getTimeUtil.timeTimer);
            var hour = getTimeUtil.extra(new Date().getHours()),
                minute = getTimeUtil.extra(new Date().getMinutes()),
                second = getTimeUtil.extra(new Date().getSeconds()),
                timeStr = "";
            timeStr = hour + ":" + minute + ":" + second;
            $(".headerTime .timeText").text(timeStr);

            if (hour == "00" && minute == "00" && second == "00") {
                console.log("转零点时:更新日期");
                getTimeUtil.getNowDate();
            } else {
                getTimeUtil.timeTimer = setTimeout(getTimeUtil.getTimeInfo, 1000);
            }
        },
        // 补零函数
        extra: function (data) {
            if (data >= 10) {
                return data;
            } else {
                return "0" + data;
            }
        },
        // 屏幕缩放
        resize:function () {
            var ratioX = $(window).width() / 1920;
            var ratioY = $(window).height() / 1080;
            if (ratioX < ratioY) {
                $(".page-container").css({
                    transformOrigin: "left top",
                    transform: "scale(" + ratioX + "," + ratioX + ")"
                });
            } else {
                $(".page-container").css({
                    transformOrigin: "center top",
                    transform: "scale(" + ratioY + "," + ratioY + ")"
                });
            }
        },
    };
    return getTimeUtil;
});

